﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TienTeTuong.BUS;
using TienTeTuong.DTO;

namespace TienTeTuong.back_end
{
    public partial class Login : System.Web.UI.Page
    {
        public AdminBUS adBus = new AdminBUS();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) {

                AdminDTO admin = new AdminDTO(txtName.Text, txtPassword.Text);

                if (adBus.isAdmin(admin)) { 
                    Session["Admin"] = admin;
                    Response.Redirect("CategoryDetailManagement.aspx");
                } else {
                    Session["Admin"] = null;
                    Label.Text = "Tài khoản hoặc mật khẩu không đúng.";
                }

            }  else if(Session["Admin"] != null){
                Response.Redirect("CategoryDetailManagement.aspx");
            }
        }
    }
}